/* const express = require('express')
const router = express.Router()


let mwRouter=(req,res,next)=>{
    console.log('全局路由中间件')
    next()
}

router.use(mwRouter)

router.get('/user',(req,res)=>{
    res.send({
        msg:'router 路由的get请求',
    })
})

router.post('/user',(req,res)=>{
    res.send({
        msg:'router 路由的post请求',
    })
})

module.exports=router */

/* const express = require('express')
const router = express.Router()

let mwRouter = (req,res,next)=>{
    console.log('全局中间件');
    next()
}

router.use(mwRouter)

router.get('./home',(req,res)=>{
    res.send('express home get with MW')
})

router.post('./home',(req,res)=>{
    res.send('express home post with MW')
})

module.exports=router */

const express = require('express')
const router = express.Router()

let mwRouter = (req,res,next)=>{
    console.log('全局中间件');
    next()
}

router.use(mwRouter)

router.get('./home',(req,res)=>{
    res.send('express home get with MW')
})

router.post('./home',(req,res)=>{
    res.send('express home post with MW')
})

module.exports=router